package com.ruoyi.file.qiniuyun;

import com.ruoyi.file.service.QiniuKodoFileServiceImpl;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.io.UnsupportedEncodingException;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("qiniukodo")
public class QiniuKodoController {

    @Resource
    QiniuKodoFileServiceImpl qiniuKodoUtil;


    @RequestMapping("upload")
    public Map<String, List<String>> upload(MultipartFile[] localFilePath) throws Exception {
        Map<String, List<String>> upload = qiniuKodoUtil.uploadImages(localFilePath);
        return upload;
    }

    @RequestMapping("listSpaceFiles")
    public void listSpaceFiles() {
        qiniuKodoUtil.listSpaceFiles();
    }

    @RequestMapping("getFileUrl")
    public void getFileUrl(String fileName) {
        try {
            qiniuKodoUtil.getFileUrl(fileName);
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
    }

    @RequestMapping("deleteFile")
    public void deleteFile(String[] fileList) {
        qiniuKodoUtil.deleteFile(fileList);
    }
}
